from tortoise import fields, models
class FoundLotTradeMatch(models.Model):
    id = fields.BigIntField(pk=True)
    record_status = fields.IntField(default=1, description="记录状态:1-有效;0-无效")
    create_time = fields.DatetimeField(description="记录创建时间", auto_now_add=True)
    update_time = fields.DatetimeField(description="记录修改时间", auto_now=True)
    lot_code = fields.CharField(max_length=50, default='', description="基金批次编码")
    found_code = fields.CharField(max_length=50, default='', description="基金编码")
    found_name = fields.CharField(max_length=200, default='', description="基金名称")
    match_type = fields.CharField(max_length=200, default='', description="核销类型：自动，手动，手动不可自动反核销，自动可以")
    match_shares = fields.DecimalField(max_digits=10, decimal_places=2, default=0.00, description="核销份额")
    buy_trade_flow_id = fields.BigIntField(null=True, description="买入ID")
    buy_price = fields.DecimalField(max_digits=10, decimal_places=4, default=0.0000, description="买入单价")
    buy_amount = fields.BigIntField(null=True, description="买入金额")
    buy_date = fields.DateField(null=True, description="买入日期")
    sell_trade_flow_id = fields.BigIntField(null=True, description="卖出ID")
    sell_price = fields.DecimalField(max_digits=10, decimal_places=4, default=0.0000, description="卖出单价")
    sell_amount = fields.BigIntField(null=True, description="卖出金额")
    sell_date = fields.DateField(null=True, description="卖出日期")
    earn_amount = fields.DecimalField(max_digits=10, decimal_places=2, default=0.00, description="盈利金额")
    earn_rate = fields.DecimalField(max_digits=10, decimal_places=2, null=True, description="盈利比例")
    remark = fields.CharField(max_length=200, default='', description="备注")

    class Meta:
        table = "found_lot_trade_match"
        table_description = "基金核销记录"

